09. Practice Solution #1

** Here are my solutions for Practice Quiz 1 questions:**

** Question 1:** Query that creates a table with the following details: actor's first and last name combined as full_name, film title and length of the movies.

SELECT a.first_name, a.last_name, a.first_name || ' ' || a.last_name AS full_name, f.title, f.length FROM film_actor fa JOIN actor a ON fa.actor_id = a.actor_id JOIN film f ON f.film_id = fa.film_id


** Question 2:** Write a query that creates a list of actors and movies where the movie length was more than 60 minutes.
SELECT a.first_name, a.last_name, a.first_name || ' ' || a.last_name AS full_name, f.title , f.length FROM film_actor fa JOIN actor a ON fa.actor_id = a.actor_id JOIN film f ON f.film_id = fa.film_id WHERE f.length > 60


** Question 3:** Write a query that captures the full name of the actor, and counts the number of movies each actor has made. Identify the actor who has made the maximum number of movies.
SELECT actorid, full_name, COUNT(filmtitle) film_count_peractor FROM (SELECT a.actor_id actorid, a.first_name, a.last_name, a.first_name || ' ' || a.last_name AS full_name, f.title filmtitle FROM film_actor fa JOIN actor a ON fa.actor_id = a.actor_id JOIN film f ON f.film_id = fa.film_id) t1 GROUP BY 1, 2 ORDER BY 3 DESC

Workspace

This section contains either a workspace (it can be a Jupyter Notebook workspace or an online code editor work space, etc.) and it cannot be automatically downloaded to be generated here. Please access the classroom with your account and manually download the workspace to your local machine. Note that for some courses, Udacity upload the workspace files onto https://github.com/udacity, so you may be able to download them there.

Workspace Information:

  • Default file path:
  • Workspace type: sql-evaluator
  • Opened files (when workspace is loaded): n/a